<?php
function DateDiff($strDate1,$strDate2,$format)
{
	$intDiv = 0;
	switch ($format) {
	    case "d": $intDiv = 60*60*24; break;
	    case "h": $intDiv = 60*60; break;
	    case "m": $intDiv = 60; break;
	}	
		
	return (strtotime($strDate2) - strtotime($strDate1))/ $intDiv ;  // 1 day = 60*60*24
}

function DateAdd($givendate,$day=0,$mth=0,$yr=0,$hr=0,$min=0,$sec=0)
{
	$cd = strtotime($givendate);
    $newdate = date('Y-m-d h:i:s', mktime(
										      date('h',$cd) + $hr
										    , date('i',$cd) + $min
										    , date('s',$cd) + $sec
										    , date('m',$cd) + $mth
										    , date('d',$cd)+ $day
										    , date('Y',$cd)+$yr
							    )
					);
    
    return $newdate;
}
?>
